package com.hd.trans.share;

import com.hd.trans.network.PreferenceMgr;

import java.util.concurrent.TimeUnit;

public class PublicBeanManager {
    private static class SingletonHolder {
        private final static PublicBeanManager instance = new PublicBeanManager();
    }

    public static PublicBeanManager getInstance() {
        return SingletonHolder.instance;
    }

    // 校验码。。
    public static final String SIGNATURE = "hUuPd20171206LuOnD";
    /**
     * productinfo 更新
     */
    public static final String mProductInfo = "F5030BB972D508DCC0CA18BDF7AE48E26717591F38906C09574D21FE92E8A040";
    public static final String mProductInfo_v4 = "F5030BB972D508DCC0CA18BDF7AE48E26717591F38906C0942F2421BAA005C21DABA7D5CE2F081DF";

    /**
     * 时间戳为本地时间+差值
     *
     * @return 秒
     */
    public Long getServiceTime() {
        return TimeUnit.MILLISECONDS.toSeconds(getServiceTimeMs());
    }

    /**
     * 时间戳为本地时间+差值
     *
     * @return 毫秒
     */
    public Long getServiceTimeMs() {
//        long serviceTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(getDeviationTime());
        long serviceTime = PreferenceMgr.getInstance().getServerTimeStamp();
        return serviceTime;
    }
//    private long getDeviationTime() {
//        /** 服务器时间非法，则使用默认的偏差时间 */
//        if (isServerTimeInvalid()) {
//            return mSp.getLong(KEY_DEVIATION_TIME, 0);
//        } else {
//            return mDeviationTime;
//        }
//    }
}
